#include "comm.hpp"
#include "log.hpp"
using namespace std;

int main()
{
    Log log;
    log.Enable(Classfile);  // 多文件打印

    // 1. 打开管道
    int fd = open(FIFO_FILE, O_WRONLY);     // 客户端写
    if(fd < 0)
    {
        log(Fatal, "server open file done, error string: %s, error code: %d", strerror(errno), errno);
        exit(FIFO_OPEN_ERR);
    }

    log(Info, "client open file done, error string: %s, error code: %d", strerror(errno), errno);
    
    string line;
    while(true)
    {
        cout << "Please Enter# ";
        getline(cin, line);
        write(fd, line.c_str(), line.size());
    }

    close(fd);
    return 0;
}